nums = [1,1,1,2,2,3]
# nums = [0,0,1,1,1,1,2,3,3]
def removeDuplicates(nums):
    removeNum=0
    last_val=nums[0]
    val_num=1
    for i in range(1,len(nums)):
        cur_val=nums[i]
        if last_val==cur_val:
            val_num+=1
        else:
            val_num=1
        if val_num>2:
            #最大数
            nums[i]=10001
            removeNum+=1

        last_val=cur_val
    nums.sort()
    nums=nums[:len(nums)-removeNum]
    print(nums)
    return len(nums)

print(removeDuplicates(nums))